/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vn.adcc.webapp.action;

import java.io.Serializable;
import java.util.List;
import vn.adcc.model.Contract;
import vn.adcc.service.ContractManager;

/**
 *
 * @author ducanh.nguyen
 */
public class ContractList extends BasePage implements Serializable {

    private ContractManager contractManager;
    private Contract contract;
    private String query;
    public ContractList(){
        setSortColumn("customerName");
    }
    public String search(){
        return "contract";
    }

    public List<Contract> getContracts() {
        if (query != null && !"".equals(query.trim())) {
            return contractManager.search(query);
        } else {
            List<Contract> contractList = contractManager.getAll();
            return sort(contractList);
        }
    }

    /**
     * @return the contractManager
     */
    public ContractManager getContractManager() {
        return contractManager;
    }

    /**
     * @param contractManager the contractManager to set
     */
    public void setContractManager(ContractManager contractManager) {
        this.contractManager = contractManager;
    }

    /**
     * @return the contract
     */
    public Contract getContract() {
        return contract;
    }

    /**
     * @param contract the contract to set
     */
    public void setContract(Contract contract) {
        this.contract = contract;
    }

    /**
     * @return the query
     */
    public String getQuery() {
        return query;
    }

    /**
     * @param query the query to set
     */
    public void setQuery(String query) {
        this.query = query;
    }
}
